package bio.demo4;

import java.io.*;
import java.net.Socket;

/**
 * @author charwayH
 * 线程实现类
 */
public class ServerRunnableTarget implements Runnable {
    private Socket socket;
    public ServerRunnableTarget(Socket socket) {
        this.socket = socket;
    }

    public void run() {
        try {
            // 处理客户端读取到的客户端需求
            InputStream is = socket.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String msg;
            while ((msg = br.readLine()) != null){
                System.out.println("服务端接收到的消息内容:" + msg);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}